package com.zzyl.mapper;


import com.github.pagehelper.Page;
import com.zzyl.entity.NursingPlan;
import com.zzyl.vo.NursingPlanVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface NursingPlanMapper {
    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    NursingPlan selectById(Integer id);

    /**
     * 新增
     *
     * @param nursingPlan
     */
    @Insert(" INSERT INTO nursing_plan (sort_no, plan_name, status, create_time,update_time, create_by, update_by, remark)\n" +
            "        VALUES (#{sortNo}, #{planName}, #{status},#{createTime} ,#{updateTime}, #{createBy}, #{updateBy}, #{remark})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(NursingPlan nursingPlan);

    /**
     * 修改
     *
     * @param nursingPlan
     */
    void update(NursingPlan nursingPlan);

    /**
     * 删除
     *
     * @param id
     */
    void deleteById(Integer id);

    /**
     * 查询所有
     *
     * @return
     */
    @Select("select * from nursing_plan")
    List<NursingPlanVo> selectPlan();

    /**
     * 分页查询
     *
     * @param name
     * @param status
     * @return
     */
    Page<NursingPlanVo> PaginationQuery(String name, Integer status);

    /**
     * 查询护理计划名称
     * @param planName
     * @return
     */
    @Select("select count(*) from nursing_plan where plan_name =#{planName} ")
    Integer nursingPlanName(String planName);

    /**
     * 护理计划启用禁用
     * @param id
     * @param status
     */
    @Update("update nursing_plan set status=#{status} where id=#{id}")
    void EnableDisableNursingPlan(Integer id, Integer status);
}